const _ = require('lodash');
const userInfoFacade = require("../../app/facade/userInfo.server.facade.js");

module.exports = {
    addUserInfo : addUserInfo,
    getUserInfoByUserId : getUserInfoByUserId
}

function addUserInfo(req, res, next){
    let body = req.body;
    userInfoFacade.addUserInfo(body);
}

function getUserInfoByUserId(req, res, next){
    let params = req.params;
    let userId = params.userId;
    if(_.isEmpty(userId)){
        return next(new Error("UserId is empty"));
    }else{
       userInfoFacade.getUserInfoByUserId(userId, (err, result) => {
           if(err){
               return next(new Error(err));
           }else{
               return res.json(result);
           }
       });

    }
}

